package com.graduation_design.modules.search.mq;

import com.graduation_design.modules.search.config.SearchRabbitConfig;
import com.graduation_design.modules.search.service.AppSearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Component
public class SearchConsumer {
    // 定义对应的接收器

    @Resource
    AppSearchService appSearchService;

    @RabbitListener(queues = SearchRabbitConfig.PRODUCT_SEARCH_CREATE_QUEUE)
    public void createListener(Long productId) {
        appSearchService.create(productId);
    }

    @RabbitListener(queues = SearchRabbitConfig.PRODUCT_SEARCH_DELETE_QUEUE)
    public void deleteListener(List<Long> productIds) {

        appSearchService.delete(productIds);
    }
}
